﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RedisLogQueueTest.CommonFunc
{
    /// <summary>
    /// 日志类实体
    /// </summary>
    public class LoggerFunc
    {
        public FileInfo logCfg;
        public log4net.ILog errorLogger;
        public string QueueName;       

        /// <summary>
        /// 保存错误日志
        /// </summary>
        /// <param name="title">日志内容</param>
        public void SaveErrorLogTxT(string title)
        {
            RedisHelper redis = new RedisHelper();
            //塞进队列的右边，表示从队列的尾部插入。
            redis.ListRightPush<string>(QueueName, title);           
        }

        /// <summary>
        /// 日志队列是否为空
        /// </summary>
        /// <returns></returns>
        public bool IsEmptyLogQueue()
        { 
            RedisHelper redis = new RedisHelper();
            if (redis.ListLength(QueueName) > 0)
            {
                return false;
            }
            return true;        
        }

    }
}
